package cn.dylan.controller;

import cn.dylan.domain.User;
import cn.dylan.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Value("${server.port}")
    private String port;

    @Autowired
    private IUserService userService;

    @GetMapping("/{id}")
    public User handlerGet(@PathVariable("id") Long id){
        return new User(id,"张三","品茶"+port);
    }

    @GetMapping("/getById/{id}")
    public User handlerFind(@PathVariable("id") Long id){
        System.out.println(id+"++++++++++++++++++++++++++++");
        return userService.loadById(id);
    }

}
